package com.zf.sqlite.utils;
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Delete;
import androidx.room.Update;
import java.util.List;

@Dao
public interface ZFEDLogsDao {
    // 插入日志
    @Insert
    long insertLog(ZFEDLogsEntity log);

    // 查询所有日志
    @Query("SELECT * FROM zfed_logs ORDER BY id DESC")
    List<ZFEDLogsEntity> getAllLogs();

    // 根据ID查询日志
    @Query("SELECT * FROM zfed_logs WHERE id = :id")
    ZFEDLogsEntity getLogById(int id);

    // 根据用户查询日志
    @Query("SELECT * FROM zfed_logs WHERE user = :user")
    List<ZFEDLogsEntity> getLogsByUser(String user);

    // 更新日志
    @Update
    int updateLog(ZFEDLogsEntity log);

    // 删除日志
    @Delete
    int deleteLog(ZFEDLogsEntity log);

    // 根据ID删除日志
    @Query("DELETE FROM zfed_logs WHERE id = :id")
    int deleteLogById(int id);

    // 删除所有日志
    @Query("DELETE FROM zfed_logs")
    int deleteAllLogs();

    // 根据日期查询日志
    @Query("SELECT * FROM zfed_logs WHERE log_time LIKE :date || '%'")
    List<ZFEDLogsEntity> getLogsByDateString(String date);

    // 根据时间范围查询日志
    @Query("SELECT * FROM zfed_logs WHERE log_time >= :startTime AND log_time <= :endTime")
    List<ZFEDLogsEntity> getLogsByTimeRange(String startTime, String endTime);

}
